﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "教学运行基础数据 - 学校信息设置");

		hosterArray = event.getArg("hosterArray");
		typeArray = event.getArg("typeArray");
		propArray = event.getArg("propArray");
	
		areaArray = event.getArg("areaArray");

		targetArgs = structNew();
	
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('classroomResource')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学场地维护</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>设置学校基础信息
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="schoolInfo">
		<li>
			<div class="clearfix" id="create">
				<div class="UItab">
					<div class="tabLables">
						<span class="active" id="labSchoolBaseInfo" tabTarget="schoolBaseInfo">学校信息</span>
						<span id="labFindSchool" tabTarget="findSchool">查找学校信息</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					function showFinder() {
						
						$("div.tabLables > span").removeClass("active");
						$("div.tabContent").hide();
						
						$("span#labFindSchool").addClass("active");
						$("div.tabContent#findSchool").show()
						
						return void(0);
					}
					
					function showForm() {
						
						$("div.tabLables > span").removeClass("active");
						$("div.tabContent").hide();
						
						$("span#labSchoolBaseInfo").addClass("active");
						$("div.tabContent#schoolBaseInfo").show()
						
						return void(0);
					}
					
					// -->
					//]]>				
				</script>
				
				<div id="findSchool" class="tabContent">
					
					<form id="formSearch" class="formWrapper Transparent" method="post">
						<div class="label">
							<b>学校名称或代码</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索学校标准信息" />
						</div>
					</form>
					
					<div id="formSearchResult" class="UICardTable">
					</div>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$("#formSearch").submit(function(){
							
							if (processVerfiyForm('formSearch')) {
								
								$.getJSON(
									'<cfoutput>#buildURL("getSchoolByKeywords")#</cfoutput>',
									{
										'Keywords': $("form#formSearch input#Keywords").val(),
										'seed': (new Date()).getTime()
									},
									function(data) {
										
										$div = $("div#formSearchResult").html("");
																				
										for (var i=0; i<data.length; i++) {
											
											var $element = $("<dl><dt><em class='campus'></em><dd><h3>" + data[i][1] + "</h3><p>(" + data[i][0] + ")</p></dd></dt></dl>");
											
											$element
												.addClass("clickAble")
												.attr({
													'SchoolID' : data[i][1],
													'SchoolName' : data[i][0]
												})
												.click(function(){
													
													var name = $(this).attr('SchoolName');
													var id = $(this).attr('SchoolID');
													
													$("form#formCreate input#SchoolID").val(name);
													$("form#formCreate input#SchoolName").val(id);
													
													showForm();
												})
												.appendTo($div);
											
										}
									});
								
							}
							
							return false;
						});
						// -->
						//]]>				
					</script>
					
				</div>
				
				<div id="schoolBaseInfo" class="tabContent">
					<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper" method="post" action="<cfoutput>#buildURL('schoolCreateDo')#</cfoutput>">
						
						<div class="label">
							<span class="req">*</span><b>学校代码</b>
							<input name="SchoolID" id="SchoolID" type="text" class="typeCode" verification="required" maxlength="5" value="<cfoutput>#event.getArg('SchoolID')#</cfoutput>" />
							<p class="notice">
								注意: 学校代码应该使用教育部颁布给当前学校的唯一代码, 参考标准《JB/GDXXHKYJG-2006 高等学校和科研机构代码》, 该代码适用于所有提交于教育部的信息的数据交换, 一旦填写则不可更改。
								<br/>
								如果您不确定学校的代码, <a href="javascript:showFinder();">请从这里进行查找</a>
							</p>
						</div>
						
						<hr/>
						
						<div class="label">
							<span class="req">*</span><b>学校正式名称</b>
							<input name="SchoolName" id="SchoolName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#event.getArg('SchoolName')#</cfoutput>" />
						</div>
						<div class="label">
							<b>英文名称</b>
							<input name="SchoolEnglishName" id="SchoolEnglishName" type="text" class="typeText typeEnglish" maxlength="180" value="<cfoutput>#event.getArg('SchoolEnglishName')#</cfoutput>" />
						</div>
						<div class="label">
							<b>建校时间</b>
							<select name="forYear" class="inlinePart">
								<cfloop from="#year(now())#" to="#(year(now())-200)#" index="_year" step="-1">
									<option value="<cfoutput>#_year#</cfoutput>"><cfoutput>#_year#</cfoutput></option>
								</cfloop>
							</select>年
							<select name="forMonth" class="inlinePart">
								<cfloop from="1" to="12" index="_month">
									<option value="<cfoutput>#numberFormat(_month, '0_')#</cfoutput>"><cfoutput>#_month#</cfoutput></option>
								</cfloop>
							</select>月
						</div>
						<hr/>
						
						<div class="label">
							<b>行政区域</b>
							<select name="forProvince" id="forProvince" class="inlinePart"></select>
							<select name="forCity" id="forCity" class="inlinePart"></select>
							<select name="forCounty" id="forCounty" class="inlinePart"></select>

							
							
							
							<cfset i = 0 />
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {

									var cityArray = [
										<cfloop from="1" to="#arrayLen(areaArray)#" index="a">
											<cfset i++ />
											<cfset id = areaArray[a][1] />
											<cfset pid = "" />
											<cfif right(id, 4) eq "0000">
												<cfset id = left(areaArray[a][1], 2) />
											<cfelseif right(id, 2) eq "00">
												<cfset id = left(areaArray[a][1], 4) />
												<cfset pid = left(areaArray[a][1], 2) />
											<cfelse>
												<cfset pid = left(areaArray[a][1], 4) />
											</cfif>
											['<cfoutput>#id#</cfoutput>','<cfoutput>#areaArray[a][2]#</cfoutput>','<cfoutput>#pid#</cfoutput>']<cfif i lt arrayLen(areaArray)>,</cfif>
										</cfloop>
										];
								
									function inputFlush(inputID, dataArray, parentID) {
									
										$("#" + inputID).removeOption(/./);
										for (var i = 0; i < dataArray.length; i++) {
											if (cityArray[i][2] == parentID) {
												$("#" + inputID).addOption(dataArray[i][0], dataArray[i][1]);
											}
										}
										$("#" + inputID).val($("#" + inputID + " option:first").attr('value'));
									}
									
									/* init SELECTs */
									inputFlush("forProvince", cityArray, "");
									inputFlush("forCity", cityArray, $("#forProvince").val());
									inputFlush("forCounty", cityArray, $("#forCity").val());
									
									$("#forProvince").change(function(){
										inputFlush("forCity", cityArray, $(this).val());
										inputFlush("forCounty", cityArray, $("#forCity").val());
									});
									
									$("#forCity").change(function(){
										inputFlush("forCounty", cityArray, $(this).val());
									});
								
								});
								// -->
								//]]>				
							</script>
							

						</div>
						<div class="label">
							<b>街道地址</b>
							<input name="SchoolAddress" id="SchoolAddress" type="text" class="typeText" maxlength="30" value="<cfoutput>#event.getArg('SchoolAddress')#</cfoutput>" />
						</div>
						<div class="label">
							<b>邮编</b>
							<input name="SchoolZipCode" id="SchoolZipCode" type="text" class="typeCode" maxlength="6" value="<cfoutput>#event.getArg('SchoolZipCode')#</cfoutput>" />
						</div>
						<hr/>

						<div class="label">
							<b>举办者</b>
							<select name="HostCode" id="HostCode">
								<!---<cfloop query="#hosterArray#">--->
                                <cfloop from="1" to="#arrayLen(hosterArray)#" index="a">
								<option value="<cfoutput>#hosterArray[a][1]#</cfoutput>"><cfoutput>#hosterArray[a][2]#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						<div class="label">
							<b>办学类型</b>
							<select name="TypeCode" id="TypeCode">
                                <cfloop from="1" to="#arrayLen(typeArray)#" index="a">
								<option value="<cfoutput>#typeArray[a][1]#</cfoutput>"><cfoutput>#typeArray[a][2]#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						<div class="label">
							<b>学校性质</b>
							<select name="PropCode" id="PropCode">
								<cfloop from="1" to="#arrayLen(propArray)#" index="a">
								<option value="<cfoutput>#propArray[a][1]#</cfoutput>"><cfoutput>#propArray[a][2]#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button" type="reset" value="重设表格" />
						</div>
					</form>
				</div>
			</div>
		</li>
	</ul>
</div>		